#ifndef _OS_MAP_H_
#define _OS_MAP_H_

#define REG_OS_IE_T2_SHIFT                                 5
#define OS_IE_TIMER2        (1UL << REG_OS_IE_T2_SHIFT) // timer2
#define REG_OS_TM0CNT_H_PS_SHIFT                           0

typedef enum
{
    OS_TIMER_0 = 0,
    OS_TIMER_1 = 1,
    OS_TIMER_2 = 2,
    OS_TIMER_3 = 3
}
OSTimer;

typedef enum
{
    OS_TIMER_PRESCALER_1 = (0UL << REG_OS_TM0CNT_H_PS_SHIFT),   // x 1
    OS_TIMER_PRESCALER_64 = (1UL << REG_OS_TM0CNT_H_PS_SHIFT),  // x 64
    OS_TIMER_PRESCALER_256 = (2UL << REG_OS_TM0CNT_H_PS_SHIFT), // x 256
    OS_TIMER_PRESCALER_1024 = (3UL << REG_OS_TM0CNT_H_PS_SHIFT) // x 1024
}
OSTimerPrescaler;

typedef void (*OSIrqFunction) (void);

typedef DWORD OSTick;
typedef u32 OSIrqMask;

#define OS_TicksToMilliSeconds(tick) tick

#define OS_Printf printf
#define OS_Panic printf

void OS_InitTick( void );
OSTick OS_GetTick( void );
void OS_Sleep( u32 msec );

void OS_WaitVBlankIntr(void);

void OS_SetIrqCheckFlag( OSIrqMask intr );
void OS_StopTimer( OSTimer id );
void OS_StartTimer( OSTimer id, u16 count, OSTimerPrescaler preScale );

void OS_SetIrqFunction( OSIrqMask intrBit, OSIrqFunction function );
OSIrqMask OS_EnableIrqMask( OSIrqMask intr );

#endif //_OS_MAP_H_